using System.Collections.Generic;
using Token = TBit.Compile.ASMCompile.Token;
using TBit.Compile;

namespace TBit.Instrcutions {
    public static class Popr {
    
        public static int Compile(List<Token> tokens,VM vm,int i) {
            return ASMCompile.StructureInstruction_OPCODE_R(Opcode.POPR,tokens,vm,i);
        }
        public static Instruction Create(RegisterIndex a) {
            Instruction inst = new Instruction();
            inst.opcode = Opcode.POPR;
            inst.args.Add(new InstructionArgData(a));
            return inst;
        }

        public static int Run(VM vm,Instruction inst){
            InstructionArgData arg1 = inst.args[0];
            if(vm.call_stack.Count > 0)
            {
                Data rm_dat = vm.MemoryPop();
                vm.WriteRegister(arg1.register,rm_dat);
            }
            return 1;
        }
    }
}